package com.nightsoul.jmemcached.server;

import java.net.InetSocketAddress;

import com.thimbleware.jmemcached.Cache;
import com.thimbleware.jmemcached.CacheElement;
import com.thimbleware.jmemcached.CacheImpl;
import com.thimbleware.jmemcached.Key;
import com.thimbleware.jmemcached.LocalCacheElement;
import com.thimbleware.jmemcached.MemCacheDaemon;
import com.thimbleware.jmemcached.storage.CacheStorage;
import com.thimbleware.jmemcached.storage.hash.ConcurrentLinkedHashMap;
import com.thimbleware.jmemcached.storage.hash.ConcurrentLinkedHashMap.EvictionPolicy;

public class Server {

	/**
	 * @param args
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static void main(String[] args) throws Exception {
		MemCacheDaemon<CacheElement> daemon = new MemCacheDaemon<CacheElement>();
		daemon.setAddr(new InetSocketAddress("localhost", 11211));
		
		CacheStorage<Key, LocalCacheElement> storage = ConcurrentLinkedHashMap.create(EvictionPolicy.LRU, 1024, 512);
		Cache cache = new CacheImpl(storage);
		daemon.setCache(cache);
		daemon.setBinary(false);
		
		daemon.start();
	}

}
